package com.service.impl;

import com.bean.Role;
import com.bean.Users;
import com.bean.vo.UserVo;
import com.mapper.RoleMapper;
import com.mapper.UsersMapper;
import com.service.RoleService;
import com.service.UsersService;
import com.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;


    @Override
    public List<UserVo> checkAll() {
        Users user=new Users();
        return usersMapper.select(user);
    }

    @Override
    public UserVo checkOne(Users r) {
      List<UserVo> list=  usersMapper.select(r);
      if(StringUtils.isEmpty(list)){

          return null;
      }else{
          return list.get(0);
        }

    }

    @Override
    public int insert(Users u) {

        u.setRoleid(2);
        return usersMapper.insert(u);
    }

    @Override
    public int update(Users u) {
        return usersMapper.update(u);
    }
}
